<%--
  Created by IntelliJ IDEA.
  User: LiuTong
  Date: 2017/11/21
  Time: 9:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="com.salesmanager.core.constants.Constants" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib prefix="sm" uri="/shopizer-tags" %>
<%@ taglib prefix="input" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<div class="container-breadcrumb">
    <div class="row ">
        <div class="col-sm-12">
            <ol class="breadcrumb">
                <li><a href="#"><span class="glyphicon glyphicon-home"></span></a></li>
                <li class="active"><s:message text="商品管理"/></li>
            </ol>
        </div>
    </div>
    <!--/.row-->
</div>
<div id="container-content" class="container-content">
    <div class="panel panel-default report-container">
        <div class="panel-heading">
            <div class="col-md-2">商品列表</div>
            <button type="button" class="btn btn-success btn-xs pull-right" id="createproduct">新建</button>
        </div>
        <div class="panel-body">
            <form:form action="${pageContext.request.contextPath}/product/productList" modelAttribute="productAttribute" method="get"
                       cssClass="row products-condition" id="myForm">
                <div class="form-inline col-sm-12">
                    <div class="form-group">
                        <label>商品ID</label>
                        <form:input id="channelCode" path="productId" cssClass="form-control"/>
                    </div>
                    <div class="form-group">
                        <label>商品名称</label>
                        <form:input id="channelName" path="productName" cssClass="form-control"/>
                    </div>
                    <div class="form-group">
                        <label>商品编码</label>
                        <form:input id="channelName" path="productCode" cssClass="form-control"/>
                    </div>
                    <div class="form-group">
                        <button id="btn_search" type="submit" class="btn btn-default">查询</button>
                    </div>
                </div>
                <form:hidden path="currentPage" id="currentPage"/>
                <form:hidden path="pageSize" id="pageSize"/>
                <input id="total" type="hidden" value="${dataList.totalCount}"/>
            </form:form>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>商品编码</th>
                    <th>商品名称</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="myTable">
                <c:forEach items="${dataList.data}" var="data">
                    <tr>
                        <td>${data.id}</td>
                        <td>${data.productCode}</td>
                        <td>${data.productName}</td>
                        <td>${data.status}</td>
                        <td>
                            <button type="button" data-id="${data.id}" class="btn btn-sm btn-block btn-primary edit" style="width: auto">
                                编辑
                            </button>
                            <button type="button" data-id="${data.id}" class="btn btn-sm btn-block btn-warning delete" style="width: auto">
                                删除
                            </button>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <div class="row">
                <div id="paginationInfo" class="col-md-4 pagination-info"></div>
                <div id="pagination" class="col-md-8"></div>
            </div>
        </div>
    </div>
</div>

<script src="${pageContext.request.contextPath}/resources/common/js/bootstrap-paginator.js"></script>
<script src="${pageContext.request.contextPath}/resources/js/common/paginator.js"></script>
<script>
    $(document).ready(function () {
        $("#createproduct").click(function(){
            window.location.href = "${pageContext.request.contextPath}/product/addProductPage";
        });

        $(".edit").click(function(){
            var id = $(this).data("id");
            window.location.href = "${pageContext.request.contextPath}/product/addProductPage?productId="+id;
        });

    })
</script>
